<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="blue">蓝色</button>
    <button id="red">红色</button>
    <button id="green">绿色</button>
</body>
</html>
<script>
var red=document.getElementById("red");
red.onclick=function(){
    document.body.style.backgroundColor='red'
}
var blue=document.getElementById("blue");
blue.onclick=function(){
    document.body.style.backgroundColor='blue'
}
var green=document.getElementById("green");
green.onclick=function(){
    document.body.style.backgroundColor='green'
}
</script>